home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
- Subject: Re: C/C++ knocks the crap out of Ada
- Date: Fri, 15 Mar 96 22:41:01 GMT
- Organization: none
- Message-ID: <826929661snz@genesis.demon.co.uk>
- References: <JSA.96Feb16135027@organon.com> <4hm6lo$eln@fred.netinfo.com.au> <4hml8s$a1q@solutions.solon.com> <DoBIoL.1JC@world.std.com> <4icai1INN608@gambier.ugrad.cs.ubc.ca>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!genesis.demon.co.uk
-
- In article <4icai1INN608@gambier.ugrad.cs.ubc.ca>
- c2a192@ugrad.cs.ubc.ca "Kazimir Kylheku" writes:
-
- >In article <DoBIoL.1JC@world.std.com>,
- >Robert A Duff <bobduff@world.std.com> wrote:
-
- > >So how can a C implementation check this range, without extending the
- > >syntax of the language? There are many other examples.
- >
- >Quite frankly, you can't do it. If the integer is not used as any sort of array
- >index, you don't know what the range is. Here are some alternatives:
- >
- >1. Use an enumerated type. Drawback: it's not an arithmetic type.
-
- The C standard defines arithmetic types to include enumerated types.
-
- > Incrementing an enumerated variable, for instance, is a no no.
-
- Maybe I'm missing your point but ++ requies an operand of a scalar type.
- It is perfectly legal for the operand to have an ennumerated type. As I
- understand it C++ is different in this respect.
-
- > An expression involving an enumerated type promotes it to an
- > int, and can't be assigned back to the enumerated type.
-
- The standard says "Each enumerated type shall be compatible with an integer
- type; the choice of type is implementation-defined". You can essentially do
- anything with an object of enumerated type that you can in general with
- integer types. Enumerated types are classed as integral types.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-